package com.itheima.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class SingletonTemplate {
    private static JdbcTemplate jdbcTemplate;

    public static JdbcTemplate getJdbcTemplate(){

        DruidDataSource druidDataSource=new DruidDataSource();
        druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
        druidDataSource.setUsername("root");
        druidDataSource.setPassword("root");
        druidDataSource.setUrl("jdbc:mysql://localhost:3306/test");

        if (jdbcTemplate!=null){
            jdbcTemplate=new JdbcTemplate();
        }
        jdbcTemplate.setDataSource(druidDataSource);
        return jdbcTemplate;

    }
}
